#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>
#include<assert.h>

typedef int SLDateType;

typedef struct SListNode
{
    SLDateType date;
    struct SListNode* next;
}SLTNode;


SLTNode* BuySListNode(SLDateType x)
{
    SLTNode* newhead = (SLTNode*)malloc(sizeof(SLTNode));
    if (newhead == NULL)
    {
        printf("malloc fail\n");
        exit(-1);
    }
    else
    {
        newhead->date = x;
        newhead->next = NULL;
        return newhead;
    }
}

void SListNodePrint(SLTNode* phead)
{
    if (phead == NULL)
    {
        printf("Link list is empty\n");
    }
    else
    {
        while (phead)
        {
            printf("%d ", phead->date);
            phead = phead->next;
        }
        printf("\n");
    }
}

void SListNodePushFront(SLTNode** pphead, SLDateType x)
{
    SLTNode* newhead = BuySListNode(x);
    newhead->next = *pphead;
    *pphead = newhead;
}

int getsize(SLTNode* phead)
{
    SLTNode* cur = phead;
    int count = 0;
    while (cur != NULL)
    {
        count++;
        cur = cur->next;
    }
    return count;
}

int SListNodeErase(SLTNode** pphead, int index)
{
    if (*pphead == NULL) return -1;
    SLTNode* cur = *pphead;
    SLTNode* prev = NULL;
    index--;
    if (index == 0) {
        prev = *pphead;
        *pphead = cur->next;
        free(prev);
        return 1;
    }
    else if (index < 0 || index >= getsize(*pphead))
    {
        return -1;
    }
    else
    {
        while (index)
        {
            prev = cur;
            cur = cur->next;
            index--;
        }
        prev->next = cur->next;
        free(cur);
        return 1;
    }
}

int SListNodeInsert(SLTNode** pphead, int index, SLDateType x)
{
    index--;
    if (index == 0)
    {
        SLTNode* newnode = BuySListNode(x);
        newnode->next = *pphead;
        *pphead = newnode;
        return 1;
    }
    else if (index < 0 || index >= getsize(*pphead))
    {
        return -1;
    }
    else
    {
        SLTNode* cur = *pphead;
        SLTNode* newnode = BuySListNode(x);
        SLTNode* prev = NULL;
        while (index)
        {
            prev = cur;
            cur = cur->next;
            index--;
        }
        prev->next = newnode;
        newnode->next = cur;
        return 1;
    }
}


void get(SLTNode* phead, int index)
{
    if (phead == NULL)
    {
        printf("get fail\n");
    }
    index--;
    if (index < 0 || index >= getsize(phead))
    {
        printf("get fail\n");
    }
    else
    {
        SLTNode* cur = phead;
        while (index)
        {
            cur = cur->next;
            index--;
        }
        printf("%d\n", cur->date);
    }
}

void Insert(SLTNode** pphead, int index, SLDateType x)
{
    int tmp = SListNodeInsert(pphead, index, x);
    if (tmp > 0)
    {
        printf("insert OK\n");
    }
    else
    {
        printf("insert fail\n");
    }
}

void delete(SLTNode** pphead, int index)
{
    int tmp = SListNodeErase(pphead, index);
    if (tmp > 0)
    {
        printf("delete OK\n");
    }
    else
    {
        printf("delete fail\n");
    }
}

void show(SLTNode* phead)
{
    SListNodePrint(phead);
}


void test01()
{
    SLTNode* plist = NULL;
    int num = 0;
    scanf("%d", &num);
    while (num)
    {
        SLDateType x = 0;
        scanf("%d", &x);
        SListNodePushFront(&plist, x);
        num--;
    }
    scanf("%d", &num);
    while (num)
    {
        char arr[10] = { 0 };
        getchar();
        int n = 0;
        SLDateType m;
        scanf("%s", arr);
        if (strcmp(arr, "get") == 0)
        {
            scanf("%d", &n);
            get(plist, n);
        }
        if (strcmp(arr, "insert") == 0)
        {
            scanf("%d%d", &n ,&m);
            Insert(&plist, n, m);
        }
        if (strcmp(arr, "delete") == 0)
        {
            scanf("%d", &n);
            delete(&plist, n);
        }
        if (strcmp(arr, "show") == 0)
        {
            show(plist);
        }
        num--;
    }
}

SLDateType findMax(SLTNode* phead)
{
    SLDateType max = phead->date;
    SLTNode* cur = phead->next;
    while (cur != NULL)
    {
        if (max < cur->date)
        {
            max = cur->date;
        }
        cur = cur->next;
    }
    return max;
}

void test02()
{
    int n = 0;
    while (scanf("%d", &n))
    {
        SLTNode* plist = NULL;
        SLDateType x;
        if (n == 0)
        {
            break;
        }
        while (n)
        {
            scanf("%d", &x);
            SListNodePushFront(&plist, x);
            n--;
        }
        SLDateType max = findMax(plist);
        printf("%d\n", max);
    }
}

int main()
{
    test02();
    return 0;
}
